/**
 * Created by XianTao on 2016/4/26
 * <p/>
 * Copyright (c) 2015-2015
 * Apache License
 * Version 2.0, January 2004
 * http://www.apache.org/licenses/
 */
package org.lego.wechat.portal.service;

public abstract class AbstractWechatHandler implements WechatHandler {
    private int priority;

    public AbstractWechatHandler() {
        WechatHandler.allHandlers.add(getMyself());
    }

    /**
     * 获取当前Handler的优先顺序，数值越小优先级越高
     *
     * @return 顺序
     */
    public int getPriority() {
        return priority;
    }

    public void setPriority(int priority) {
        this.priority = priority;
    }

    public int compareTo(WechatHandler weChatHandler) {
        if (weChatHandler.getPriority() == getPriority()) {
            return 0;
        } else if (weChatHandler.getPriority() < getPriority()) {
            return 1;
        } else {
            return -1;
        }
    }
}
